<cfscript>    
    view = createObject("component", session.rootDir & ".views.layout");
    if( Session.Auth EQ True and (Session.strAuthType EQ Session.MANAGERS or Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) ){
		view.init("Step 3:  Termination Schedule",
			"/jquery/ui-1.8.5/jquery-ui.min.js,/jquery/plugins/scrollTo/jquery.scrollTo-1.4.2-min.js, /" & session.rootDir & "/static/js/SCF/Step3-TermSchedule.js",
			"/jquery/ui-1.8.5/themes/cupertino/jquery-ui.css","Home",main, "Termination");
    }else{
        view.init("Denied","","","Home","Denied");
    }    
    view.html();
</cfscript>

<cffunction name="main" access="public" output="true" returntype="any">
    <cfparam default="-1" name="url.TermReqID" />
    <cfscript>
        import models.*;
        FormAction = '/' & session.rootDir & '/controller/SubmitHandlerTermination.cfm?SCFStep3=update_term_schedule';
        KronosQueries = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos");
        StepActions = ORMExecuteQuery("FROM StepActions WHERE StepsID = 23 AND ActTimeStamp IS NULL");
    </cfscript>
    
    <cfoutput> 
    <h1 class="title">Step 3:  Termination Schedule</h1>
        <div class="entry">    
            Welcome, #Session.EmpInfo.FirstName# #Session.EmpInfo.LastName#.  
            This report is provided as a "read only" reference for those 
            individuals who are scheduled to be terminated at a later 
            date.<br /><br />

            <cfform name="MyForm" action="#FormAction#">
                <cfif ArrayLen(StepActions) GT 0>
                    <table cellspacing="1" cellpadding="2">                
                        <tr>
                            <td>&nbsp;</td>
                            <td><strong>Employee</strong></td>
                            <td><strong>Supervisor</strong></td>
                            <td><strong>Requestor</strong></td>                
                            <td><strong>Effective Date</strong></td>
                            <td><strong>HR Date</strong></td>
                            <td>&nbsp;</td>
                        </tr>
                        <cfloop from="1" to="#ArrayLen(StepActions)#" index="i">
                            <cfset TermDetails = entityLoadByPK("TerminationRequests", StepActions[i].getTermReqID()) />
                            <cfset Employee = KronosQueries.funcGetAllEmployees( TermDetails.getRosettaID()) />                                                        
                            <cfset Supervisor = KronosQueries.funcGetCurrentEmployeeByID( Employee.SupervisorIdNo ) />
                            <cfset Requestor = KronosQueries.funcGetAllEmployees( StepActions[i].getActionByID() ) />

                            <tr id="#TermDetails.getTerminationRequestsID()#">
                                <td width="1%">#i#.)</td>
                                <td>#Employee.FirstName# #Employee.LastName#</td>
                                <td>#Supervisor.FirstName# #Supervisor.LastName#</td>
                                <td>#Requestor.FirstName# #Requestor.LastName#</td>
                                <td><cfinput type="text" name="TermDate#TermDetails.getTerminationRequestsID()#" size="13" value='#DateFormat(TermDetails.getTermDate(),"mm/dd/yyyy")#' error_message="Effective termination date must be given." /></td>
                                <td><cfinput type="text" name="SysTermDate#TermDetails.getTerminationRequestsID()#" size="13" value='#DateFormat(TermDetails.getSysTermDate(),"mm/dd/yyyy")#' error_message="HR termination date must be given." /></td>
                                <td><cfinput type="button" name="TermReqID#TermDetails.getTerminationRequestsID()#" value='Save' /></td>
                                <!--- JS file Step3-TermSchedule.js handles form submition --->
                            </tr>
                            
                        </cfloop>
                    </table>            
                <cfelse>
                    <span class="error">At the present time, there are not any employees scheduled for termination.</span>
                </cfif>
                <cfinput type="hidden" name="FormAction" value="#FormAction#">
                <cfinput type="hidden" name="Images" value="/#session.rootDir#/images/">
            </cfform>
        </div>    
    </cfoutput>
    
</cffunction>